﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using IWMAG.Core.EnhancedProperties.PropertyNodes;

namespace IWMAG.Core.EnhancedProperties
{
    public class PropertyContainerBase : IPropertyContainer, IDisposable
    {
        protected PropertyContainerBase()
        {
            _uniqueID = UniqueIdentifier.CreateNew();
        }


        private readonly UniqueIdentifier _uniqueID;
        UniqueIdentifier IPropertyContainer.UniqueID
        {
            get
            {
                return _uniqueID;
            }
        }

        /// <summary>
        /// Always call the base.Dispose() if overriden.
        /// </summary>
        public virtual void Dispose()
        {
            PropertyManager.DisposingObject((this as IPropertyContainer).UniqueID);
        }
    }
}
